<?php $pageRange = 6; ?>
<?php $pageStart = ($pageRange >= $page->current) ? $page->first : ($page->current - $pageRange); ?>
<?php $pageEnd = (($page->current + $pageRange) > $page->total_pages ) ? $page->total_pages : ($page->current + $pageRange); ?>
<?php if ($page->total_pages > 1): ?>
    <ul class="paginator"> 
        <?php if ($page->current != $page->first): ?>
            <li><?= $this->tag->linkTo(str_replace('{pn}', $page->first, $uriTemplate), "首页") ?></li>
            <li><?= $this->tag->linkTo(str_replace('{pn}', $page->before, $uriTemplate), "上一页") ?></li>
        <?php endif; ?>
        <?php if ($pageStart > $page->first): ?>
            <li>...</li>
        <?php endif; ?>
        <?php for ($i = $pageStart; $i <= $pageEnd; $i++): ?>
            <?php if ($i == $page->current): ?>
                <li><?= $i ?></li>
            <?php else: ?>
                <li><?= $this->tag->linkTo(str_replace('{pn}', $i, $uriTemplate), $i) ?></li>
            <?php endif; ?>
        <?php endfor; ?>
        <?php if ($page->total_pages > $pageEnd): ?>
            <li>...</li>
        <?php endif; ?>
        <?php if ($page->current != $page->last): ?>
            <li><?= $this->tag->linkTo(str_replace('{pn}', $page->next, $uriTemplate), "下一页") ?></li>
            <li><?= $this->tag->linkTo(str_replace('{pn}', $page->last, $uriTemplate), "末页") ?></li>
        <?php endif; ?>
        <span>共<?= $page->total_pages ?>页</span>
    </ul>
<?php endif; ?>